<template>
	<view>
		<view class="goods_desc_container"   >
     <radio v-if="isShow" @click="toggleCheck(item.goods_id)" :checked='item.goods_state' color="#C00000"></radio>
		  <view class="imag_box" @click="to_goodsDetail(item.goods_id)">
		    <!-- 左侧盒子-->
		   
		    <image  :src="item.goods_small_logo||defaultPic" mode=""></image>
		  </view>
		  <view class="dec_box">
		    <!-- 右侧盒子-->
		    <text>{{item.goods_name}}</text>
		<view class="count">
		  <view class="price">
		    {{item.goods_price|price}}
		  </view>
		   <!-- 商品数量 -->
       
		      <uni-number-box v-if="showAdder" :min="1"  @change="updataCount($event,item.goods_id)" :value="item.goods_count"></uni-number-box>
		</view>
		  </view>
		</view>
	</view>
</template>

<script>
  import {mapState,mapMutations} from 'vuex'
	export default {
  
    filters:{
      price(value){
        if(value){
          return '￥'+value.toFixed(2)
        }
      }
    },
    props:{
      showAdder:true,
      isShow:{
        type:Boolean,
        default:false
      },
      m_checked:{
        type:Boolean,
        default:true
      },
      defaultPic:{
        type:String,
        default:'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png'
      },
      item:{
        type:[Array,Object],
        default:{}
      }
    },
		data() {
			return {
      numbers:1
			};
		},
    computed:{
      // ...mapState['m_cart/cart']
      ...mapState('m_cart',['cart']),
    },
    // watch:{
    //   numbers(){
    //     this.updataCount()
    //   }
    // },
    methods:{
      ...mapMutations('m_cart',['saveCart']),
      updataCount(e,ids){
        this.$emit('change_number',{
          goods_id:ids,
          goods_count:+e
        })

      // const goods= this.cart.find(x=>x.goods_id==ids)
      // console.log('查找', goods )
      // goods.goods_count=e
      //   this.$store._mutations['m_cart/total1'][0]()
      },
      to_goodsDetail(ids){
        uni.navigateTo({
          url:'/subpkg/goods_detail/goods_detail?goodsId='+ids
        })
      },
      toggleCheck(ids){
       this.$emit('click',ids)
      }
    }
	}
</script>

<style lang="scss">
.goods_desc_container{
  width: 750rpx;
  box-sizing: border-box;
  border-top: 1px solid #f7f8f7;
  display: flex;
  // padding: 10px 10px;
  padding: 10px 0;
  padding-left: 10px;
  
  align-items: center;
  // justify-content: space-between;
  .imag_box{
    image{
      width: 200rpx;
      height: 250rpx;
    }
  }
  .dec_box{
    display: flex;
    flex-direction: column;
   justify-content: space-around;
    text{
      font-size: 12px;
    }
    view{
      color: #c00000;
    }
  }
}
.count{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}
</style>
